const request = require("request");
const { stringify } = require("qs");
const { BASE_URL } = require("./config");

module.exports = (req, res) => {
  const url = `${BASE_URL}/explore/v2/getRecommend?${stringify({
    useCache: true,
    clientType: 1,
  })}`;
  // console.log("url>>>", url);
  request(
    {
      url,
      headers: {
        "xm-sign": req.sign,
      },
    },
    (error, response, body) => {
      if (error) {
        console.log("error aa", error);
        res.status(500).json({
          ret: 0,
          message: "猜你喜欢请求失败",
          data: error,
        });
      } else {
        res.status(response.statusCode).json(JSON.parse(body));
      }
    }
  );
};
